package labs.laba_02;

import java.util.ArrayList;

public class TV {
	public static final byte MAX_CHANNELS = 100;
	private ArrayList<CharSequence> channels = new ArrayList<CharSequence>();
	private boolean power = false;
	private byte currentChannel = 1;

	public boolean getPower(){
		return this.power;
	}
	public void setPower(boolean p){
		this.power = p;
	}
	public byte getCurrentChannelIndex(){
		return currentChannel;
	}
	public boolean setCurrentChannelIndex(byte newCh){
		if(newCh>=1 && newCh<=MAX_CHANNELS){
			currentChannel = newCh;
			return true;
		}
		return false;
	}
	public CharSequence getChannelCaption(byte i){
		if(0<i && channels.size()>=i){
			return channels.get(i);
		}
		return "\0";
	}
	public boolean setChannelCaption(byte i, CharSequence c){
		if((0<i && channels.size()>=i) && (c.length()>0)){
			channels.set(i, c.toString().trim()); 
			return true;
		}
		return false;
	}
}
